<template>
    <div>
        <button @click="getALoveSentence">获取一句土味情话</button>
        <ul>
            <li v-for=" l in talkStore.talkList " :key="l.id">
                {{ l.content }}
            </li>
        </ul>
    </div>
</template>

<script setup lang="ts">
import { useTalksStore } from '@/store/talks';

const talkStore = useTalksStore()
//侦听 talkStore 的变化
talkStore.$subscribe((mutate,state)=>{
    console.log('LoveTalk subscribe....',mutate,state);
    //这里是将数据存储在浏览器的LocalStorage中 内容形式是 key-value 形式 
    localStorage.setItem('talk',JSON.stringify(talkStore.talkList))
})



async function getALoveSentence() {
    talkStore.getImg()
}
</script>

<style scoped></style>